'use strict';

const mongoose = require('mongoose'),
      MerchantInfoSchema = require('./merchantInfo.model.js');

const ComplaintsModel = new mongoose.Schema({
    cname: String,
    reason: String,
    merchant: MerchantInfoSchema,
    status: String,
    dealTime: Date,
    complaintsTime: Date
},{
    collection: 'complaints'
});

ComplaintsModel.pre('save', function (next) {
    var doc = this;
    doc.complaintsTime = new Date();
    doc.dealTime = new Date();
    doc.status = '2';
    console.log("pre complaints save hook!!!")
    console.log(doc)
    next();
});

mongoose.model('complaints', ComplaintsModel);